package org.ims.inv.service.system.impl;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.ims.inv.dao.system.DAOAppLog;
import org.ims.inv.model.system.ModelAppLog;
import org.ims.inv.service.system.ServiceAppLog;

import cn.trymore.core.service.impl.ServiceGenericImpl;
import cn.trymore.core.util.UtilString;

/**
 * Service: 系统用户
 * 
 * @author Jeccy.Zhao
 *
 */
public class ServiceAppLogImpl
extends ServiceGenericImpl<ModelAppLog> implements ServiceAppLog
{
	/**
	 * The repository of application user.
	 */
	private DAOAppLog daoAppLog;
	
	public ServiceAppLogImpl(DAOAppLog dao)
	{
		super(dao);
		this.daoAppLog = dao;
	}
	
	/*
	 * (non-Javadoc)
	 * @see cn.trymore.core.service.impl.ServiceGenericImpl#getCriterias(cn.trymore.core.model.ModelBase)
	 */
	@Override
	protected DetachedCriteria getCriterias(ModelAppLog entity)
	{
		DetachedCriteria criteria = DetachedCriteria.forClass(ModelAppLog.class);
		
		if (entity != null)
		{
			if (UtilString.isNotEmpty(entity.getLogType()))
			{
				criteria.add(Restrictions.like("logType", entity.getLogType(), MatchMode.ANYWHERE));
			}
			
			if (UtilString.isNotEmpty(entity.getLogOperator()))
			{
				criteria.add(Restrictions.like("logOperator", entity.getLogOperator(), MatchMode.ANYWHERE));
			}
		}
		
		criteria.addOrder(Order.desc("logCreationTime"));
		
		return criteria;
	}
	
	public void setDaoAppLog(DAOAppLog daoAppLog)
	{
		this.daoAppLog = daoAppLog;
	}

	public DAOAppLog getDaoAppLog()
	{
		return daoAppLog;
	}
	
}
